<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>短信快捷登录</title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link rel="icon" href="img/favicon.ico" mce_href="http://pd51ux91p.bkt.clouddn.com/favicon.ico" type="image/x-icon">
	<link rel="stylesheet" type="text/css" href="css/commonality.css"/>
	<link rel="stylesheet" type="text/css" href="css/login2.css"/>
	<script src="//cstaticdun.126.net/load.min.js"></script>
	<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/layer.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
	<div class="pc" style="display: none;">
		<!--头部导航菜单-->
		<div class="top">
			<div class="top_div">
				<a class="logo" href="index.html"><img src="http://pd51ux91p.bkt.clouddn.com/public/logo.png"/></a>
				<ul><li><a href="index.html">首页</a></li>
					<li><a href="game.html">游戏</a></li>
					<li><a href="edg.html">战队</a></li>
					<li><a href="guide.html">办赛指南</a></li>
					<li><a href="userCenter.html">注册/登录</a></li>
					<li><a href="javascript:;">创建战队</a></li>
				</ul>
			</div>
		</div>
		
		<!--主体-->
		<div class="main dis_block">

			<!--游戏KV-->
			<div class="banner">
				<div class="banner_bg banner_bg1"></div>
				<div class="banner_bg banner_bg2"></div>
				<div class="banner_bg banner_bg3"></div>
				<div class="banner_bg banner_bg4"></div>
				<div class="banner_bg banner_bg5"></div>
			</div>
			
			<!--游戏新闻-->
			<div class="GamesList">
				<div class="GamesList_div">
					
				</div>
			</div>
			
			<!--直播-->
			<div class="live" id="ambassador">
				<p>赛事标题</p>
				<div class="live_div">
					<!--直播视频-->
					<div class="sinatv">
						
					</div>
					<!--赛事竞猜-->
					<div class="guess">
						
					</div>
				</div>
			</div>
		
			<!--赛事奖金-->
			<div class="bonus">
				<div class="bonus_div">
					<!--战队榜-->
					<div class="edg">
						
					</div>
					<!--赛事榜-->
					<div class="Competition">
						
					</div>
				</div>
			</div>
		
			
			<!--联系我们-->
			<div class="about" id="about">
				<div class="about_main">
					<p class="about_title">联系我们</p>
					<p class="about_describe">我们总是乐于帮助你，请选择最适合你的方式联系我们！ </p>
					<div class="about_address">
						<p style="margin-top: 8px;">总址：上海市闵行区虹井路288号B座703室</p>
						<p>分部：广州市天河区广州信息港方圆E时光西座28楼</p>
						<p>邮编：510000</p>
						<p>电话：+86 13901779476</p>
						<p>&nbsp;</p>
						<p>网址：www.juyouxiao.com</p>
						<p>E-mail：hr@tianchangtech.com</p>
					</div>
					
					
					<div class="toastInfo"><span>提醒</span></div>
				</div>
				<ul class="foot">
					<li><a href="index.html">首页</a></li>
					<li><a href="javascript:;">校园大使</a></li>
					<li><a href="javascript:;">关于我们</a></li>
				</ul>
				<p class="provider">京公网安备11010802023605号</p>
			</div>
		</div>
		
		<!--点击回到顶部-->
		<a id="com_d" style="display: none;"></a>
	</div>
	
	<div class="mobile" style="display: block;">
		<div class="main loginnote dis_block">
			<img class="loginBG loginBG1" src="http://pd51ux91p.bkt.clouddn.com/login/loginBG1.jpg"/>
			<div class="topDiv fix"><img src="http://pd51ux91p.bkt.clouddn.com/public/logo.png"/></div>
			<div class="content fix">
				<div class="module">
					<label for="MobileNumber">手机号</label>
					<div class="MobileDIV">
						<input class="inputClass MobileNumber" type="number" name="" id="MobileNumber" value="" placeholder="请输入手机号码" onkeyup="judgeIsNonNull1(event)" />
					</div>
					
					<img class="telClear dis_none" src="http://pd51ux91p.bkt.clouddn.com/public/delicon.png">
				</div>
				<div id="captcha"></div>
				<div class="module">
					<label for="VerificationCode">验证码</label>
					<div class="CodeDiv">
						<input class="inputClass VerificationCode" type="text" name="" id="VerificationCode" value="" placeholder="请输入验证码" onkeyup="judgeIsNonNull2(event)" />
					</div>
					<img class="codeClear dis_none" src="http://pd51ux91p.bkt.clouddn.com/public/delicon.png">
					<button class="acquire" id="acquire" type="button">获取短信验证码</button>
				</div>
				<button class="ringUp submit" id="ringUp" type="button">登录</button>
			</div>
		</div>
	</div>

	<script src="js/sUserAgent.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		function judgeIsNonNull1(event){
			var value=$("#MobileNumber").val();
			var x = event.which || event.keyCode;
			if (x == 8 ) {
		  		if(value !== "" ){
			      	$(".telClear").removeClass("dis_none");
			    }else{
			    	$(".telClear").addClass("dis_none");
			    }
			}
			if(value !== "" ){
				if( value.length > 11 ){
		    		return $("#MobileNumber").val(value.substr(0, 11));
		    	}
		    	$(".telClear").removeClass("dis_none");
		    }else{
		    	$(".telClear").addClass("dis_none");
		    }
		}
		function judgeIsNonNull2(event){
		  	var value=$("#VerificationCode").val();
		  	var x = event.which || event.keyCode;
			if (x == 8 ) {
			  	if(value !== ""){
			      	$(".codeClear").removeClass("dis_none");
			    }else{
			    	$(".codeClear").addClass("dis_none");
			    }
		  	}
			if(value !== ""){
				if( value.length > 6 ){
		    		return $("#VerificationCode").val(value.substr(0, 6));
		    	}
		    	$(".codeClear").removeClass("dis_none");
		    }else{
		    	$(".codeClear").addClass("dis_none");
		    }
		}
		
		$('.telClear').click(function(){
		    $('#MobileNumber').val("");
		    $(".telClear").addClass("dis_none");
		});
		$('.codeClear').click(function(){
		    $('#VerificationCode').val("");
		    $(".codeClear").addClass("dis_none");
		});



	//	以下为触发 【发送验证码  按钮  开始
		function show_img_authcode(){
		    initNECaptcha({
		    	captchaId: '7fbd905f961c4867925243886f466e81',
		      	element: '#captcha',
		      	mode: 'popup',
		      	protocol: 'https',
		      	width: 320,
		      	onReady: function (instance) {
		        // 验证码一切准备就绪，此时可正常使用验证码的相关功能
		      	},
		      	onVerify: function (err, data) {
			        if(!data || !data.validate){
			          	layer.msg("请重试");
			          	return;
			        }
			        send_authcode(data.validate);
			    }
		    }, function onload (instance) {
		      	// 初始化成功
		      	instance.popUp();
		    });//initNeCaptcha
	    }
		
	    function send_authcode(validate){
		   	$.ajax({
		   			type:"post",
			        url: '/api/phonequickeck/', 
			        data: JSON.stringify({
			          	mobile: $('#MobileNumber').val(),
			          	img_validate: validate,
			          	type :1
			        }), 
			        contentType:"application/json",
			        dataType: "json",
			        success: function(res) {
			        	if(res.code == 0){
			        		setCookie("yz_last_id",res.last_id)
				            i=60;
				            e=setInterval(resendVal,1000);
			        	}else{
			        		layer.msg(res.msg)
			        	}
			        }
			    });
	    }
	
	    function bind_mobile(authcode){
		    $.ajax({
		        url: '/app/user/bind_mobile', 
		        type: "POST",
		        data: {
		          	mobile: $('#MobileNumber').val(),
		          	authcode: authcode 
		        }, 
		        dataType: "json",
		        success: function(res) {
		          	layer.msg(res.msg);
		          	if(res.status == 0){ }
		            
		        }
		    });
	    }
	   
	   
		//以下为  手机验证码 JS代码
		var i=60;
		var e;
		function resendVal(){
		    i--;
		    if( i==0 ){
		      	$('.acquire').text("重新获取");
		      	$('.acquire').css({'color':'rgba(212, 212, 212, 0.6)','border':'1px solid rgba(136, 136, 136, 0.52)'});
		      	$(".acquire").removeAttr('disabled');
		      	clearInterval(e);
		    }else{
		      	$('.acquire').css({'color':'#6e6e6e','border':'1px solid rgba(110, 110, 110, 0.1)'});
		      	$(".acquire").attr('disabled','true');
		      	$('.acquire').text("剩余时间"+i+"s");
		    }
		}
	   //发送短信验证码
		$('#acquire').click(function(){
			console.log(1111111)
		    var telephone =$('#MobileNumber').val();
		    var reg=/(1[3-9]\d{9}$)/;
		    if(!telephone){
		    	layer.msg('手机号码不能为空！');
		    	return false;
		    } else if(!reg.test(telephone)){
		    	layer.msg('请输入正确格式的手机号码！');
		    	return false;
		    } else{
		    	show_img_authcode()
		    	// layer.msg('发送成功！');
		    	// i=60;
		    	// e=setInterval(resendVal,1000);
		    }
	//	    show_img_authcode();
		});

	//	触发 【发送验证码  按钮  结束
		team_id = getUrlParms('team_id');
	    if (typeof(team_id)!='string'){
	        team_id =0
	    }

		
		//提交  登录
		$("#ringUp").on("click",function(){
			var VerificationCode = $("#VerificationCode").val();
			
			var telephone=$('#MobileNumber').val();
			var reg=/(1[3-9]\d{9}$)/;
		    if(!telephone){
		    	layer.msg('手机号码不能为空！');
		    	return;
		    } else if(!reg.test(telephone)){
		    	layer.msg('请输入正确格式的手机号码！');
		    	return;
		    }
			if( VerificationCode == "" ){
				layer.msg("验证码不能为空");
				return false;
			}

			if( telephone !== "" && VerificationCode !== "" && getCookie("yz_last_id")!=null){
			   	$.ajax({
			   			type:"post",
				        url: '/api/phonequicklogin/', 
				        data: JSON.stringify({
				          	mobile: telephone,
				          	VerificationCode: VerificationCode,
				          	last_id:getCookie("yz_last_id") 
				        }), 
				        contentType:"application/json",
				        dataType: "json",
				        success: function(res) {
				        	if (res.code ==0){
								layer.msg("登陆成功！");
				        		setCookie("yz_tk",res.token)
				        		setCookie("yz_id",res.user_id)
				        		delCookie("yz_last_id")
				        		window.location.href = 'index.html'
				        	}else{	
				        		layer.msg(res.msg)
				        	}
				        },
				        error:function(res){

				        }
				    });
			}
		});

	</script>
</body>
</html>

